<template>
    <div class="leftmsg">
        <titleItem titletext="销售排行榜" style="flex-shrink: 0;">
            <div class="scroll-wrap">
                <el-carousel height="150px" :motion-blur="true" autoplay arrow="never" direction="vertical"
                    indicator-position="none" :interval="2000" loop>
                    <el-carousel-item class="item" v-for="(item, index) in props.ranklist" :key="index">
                        <div class="headImg">
                            <img v-if="index === 0" class="crown" src="./assets/img/crown-1.png" alt="">
                            <img v-if="index === 1" class="crown" src="./assets/img/crown-2.png" alt="">
                            <img v-if="index === 2" class="crown" src="./assets/img/crown-3.png" alt="">
                            <img class="img" :src="(item as any).salesHeadURL" alt="">
                        </div>
                        <div class="personmsg">
                            <div class="flex-col gap-10px">
                                <div class="topThree" v-if="index === 0 || index === 1 || index === 2">NO.{{ index +
                                    1
                                    }}</div>
                                <div class="afterThree" v-else>NO.{{ index + 1 }}</div>
                                <div class="fs-18 fc-ffffff fw-600">{{ (item as any).saleName }}</div>
                            </div>
                            <div class="flex-col gap-10px">
                                <div class="fs-14 fc-ffffff">小组名称</div>
                                <div class="fs-18 fc-ffffff fw-600">{{ (item as any).deptName }}</div>
                            </div>
                            <div class="flex-col gap-10px">
                                <div class="fs-14 fc-ffffff">销售额</div>
                                <div class="gradient-text fw-600">{{ formatCurrency((item as any).totalPerformance,
                                    '¥',
                                    2) }}
                                </div>
                            </div>
                        </div>
                    </el-carousel-item>
                </el-carousel>
                <!-- <vue3-seamless-scroll :list="props.ranklist" :hover="true" :isWatch="true" class="scroll">
                    <div class="item" v-for="(item, index) in props.ranklist" :key="index">
                        <div class="headImg">
                            <img v-if="index === 0" class="crown" src="./assets/img/crown-1.png" alt="">
                            <img v-if="index === 1" class="crown" src="./assets/img/crown-2.png" alt="">
                            <img v-if="index === 2" class="crown" src="./assets/img/crown-3.png" alt="">
                            <img class="img" :src="(item as any).salesHeadURL" alt="">
                        </div>
                        <div class="personmsg">
                            <div class="flex-col gap-10px">
                                <div class="topThree" v-if="index === 0 || index === 1 || index === 2">NO.{{ index + 1
                                    }}</div>
                                <div class="afterThree" v-else>NO.{{ index + 1 }}</div>
                                <div class="fs-18 fc-ffffff fw-600">{{ (item as any).saleName }}</div>
                            </div>
                            <div class="flex-col gap-10px">
                                <div class="fs-14 fc-ffffff">小组名称</div>
                                <div class="fs-18 fc-ffffff fw-600">{{ (item as any).deptName }}</div>
                            </div>
                            <div class="flex-col gap-10px">
                                <div class="fs-14 fc-ffffff">销售额</div>
                                <div class="gradient-text fw-600">{{ formatCurrency((item as any).totalPerformance, '¥',
                                    2) }}
                                </div>
                            </div>
                        </div>
                    </div>
                </vue3-seamless-scroll> -->
            </div>
        </titleItem>
        <titleItem :titletext="'部门数据（共：' + totalCount + '人）'" style="flex-shrink: 0;">
            <vue3-seamless-scroll :list="props.ranklist" :hover="true" :isWatch="true" class="deptData">
                <div v-for="(item, index) in deptList" :key="index" class="deptlist-item">
                    <div class="name">{{ item.deptName }}</div>
                    <div class="line">
                        <div class="inner-line" :style="{ width: `${item.width}` }">
                            <div class="point">
                                <div class="shado"></div>
                            </div>
                        </div>
                        <div class="fc-ffffff fs-16" style="flex-shrink: 0; margin-left: 25px">{{ item.num }}<span
                                style="color: rgba(255, 255, 255, 0.5);font-size: 12px">人</span>
                        </div>
                    </div>
                </div>
            </vue3-seamless-scroll>
        </titleItem>
    </div>
</template>

<script setup lang="ts">
import { formatCurrency } from '../../../utils/utils'
import titleItem from './components/titleItem.vue'
import { Vue3SeamlessScroll } from 'vue3-seamless-scroll'
import { ref, reactive, computed, watch, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { getBiDeptInfoApi } from '../../../api/visualization/visualization'
// const router = useRouter()
// const route = useRoute()
const props = defineProps({
    ranklist: {
        type: Array,
        required: true,
    }
})
onMounted(() => {
    getBiDeptInfoApi({}).then((res: any) => {
        console.log(res, '部门信息')
        let total = 0
        let max = 0
        res.forEach((item: any) => {
            total += item.peopleCount
            if (max < item.peopleCount) {
                max = item.peopleCount
            }
        })
        totalCount.value = total
        deptList.value = res.map((item: any) => {
            return {
                width: `${item.peopleCount / max * 100}%`,
                deptName: item.deptName,
                num: item.peopleCount,
            }
        })
    })
})
const totalCount = ref(0)
const deptList = ref([
    {
        width: '10%',
        deptName: '重庆运营中心',
        num: 10,
    },
    {
        width: '20%',
        deptName: '财务部',
        num: 10,
    },
    {
        width: '30%',
        deptName: '客服部',
        num: 10,
    },
    {
        width: '40%',
        deptName: '报白',
        num: 10,
    },
    {
        width: '50%',
        deptName: '长沙运营中心',
        num: 10,
    },
    {
        width: '60%',
        deptName: '保险',
        num: 10,
    },
    {
        width: '60%',
        deptName: '重庆运营中心',
        num: 10,
    },
    {
        width: '70%',
        deptName: '广州运营中心',
        num: 10,
    },
    {
        width: '80%',
        deptName: '税筹',
        num: 10,
    },
    {
        width: '90%',
        deptName: '闪客',
        num: 10,
    },
])
const list = ref([
    {
        deptName: '娃哈哈1',
        price: '111',
        name: '佘颖欣',
        img: 'https://pic.imgdb.cn/item/660cc5199f345e8d03b105ec.jpg'
    },
    {
        deptName: '娃哈哈2',
        price: '111',
        name: '章若楠',
        img: 'https://pic.imgdb.cn/item/660cc4df9f345e8d03afb78b.jpg'
    },
    {
        deptName: '娃哈哈3',
        price: '111',
        name: '佘颖欣',
        img: 'https://pic.imgdb.cn/item/660cc5199f345e8d03b105ec.jpg'
    },
    {
        deptName: '娃哈哈4',
        price: '111',
        name: '章若楠',
        img: 'https://pic.imgdb.cn/item/660cc4df9f345e8d03afb78b.jpg'
    },
    {
        deptName: '娃哈哈5',
        price: '111',
        name: '佘颖欣',
        img: 'https://pic.imgdb.cn/item/660cc5199f345e8d03b105ec.jpg'
    },
    {
        deptName: '娃哈哈6',
        price: '111',
        name: '章若楠',
        img: 'https://pic.imgdb.cn/item/660cc4df9f345e8d03afb78b.jpg'
    },
    {
        deptName: '娃哈哈7',
        price: '111',
        name: '苏念',
        img: 'https://pic.imgdb.cn/item/660cc4d99f345e8d03af9753.jpg'
    },
    {
        deptName: '娃哈哈8',
        price: '111',
        name: '佘颖欣',
        img: 'https://pic.imgdb.cn/item/660cc5199f345e8d03b105ec.jpg'
    },
    {
        deptName: '娃哈哈9',
        price: '111',
        name: '苏念',
        img: 'https://pic.imgdb.cn/item/660cc4d99f345e8d03af9753.jpg'
    },
])
const a = () => {
    console.log(111, 'gysghuysd')

}
defineExpose({
    a
})
</script>

<style lang="scss" scoped>
.deptList {
    margin-top: 12px;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 30px;

    .deptlist-item {
        display: flex;
        align-items: center;
        height: 40px !important;
        margin-bottom: 30px !important;
        gap: 4px;

        .name {
            flex-shrink: 0;
            width: 80px;
            color: #ffffff;
            font-size: 12px;
            text-align: end;
        }

        .line {
            width: 100%;
            height: 10px;
            display: flex;
            align-items: center;

            .inner-line {
                position: relative;
                height: 8px;
                background: linear-gradient(269deg, #1B7EF2 0%, rgba(27, 126, 242, 0) 99%);

                .point {
                    position: absolute;
                    right: -20px;
                    top: -8px;
                    width: 20px;
                    height: 20px;
                    border-radius: 50%;
                    border: 1px solid #1B7EF2;
                    background-color: #161616;
                    display: flex;
                    align-items: center;
                    justify-content: center;

                    .shado {
                        width: 5px;
                        height: 5px;
                        background: #FFFFFF;
                        border-radius: 50%;
                        border: 0.83px solid #1B7EF2;
                        box-shadow: 0px 0px 4.17px 1px rgba(255, 255, 255, 0.44);
                    }
                }
            }
        }
    }
}

.flex1 {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-around;
    flex-direction: column;
    gap: 20px;
}

.dept-top-bg {
    width: 100%;
    box-sizing: border-box;
    height: 47px;
    background-image: url('./assets/img/dept-top-bg.png');
    background-repeat: no-repeat;
    background-size: 100% 100%;
    padding: 0 6px 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.deptData {
    width: 100%;
    height: calc(100vh - 526px);
    overflow: hidden;
    box-sizing: border-box;
    padding: 16px 8px;

    .deptlist-item {
        display: flex;
        align-items: center;
        height: 40px !important;
        gap: 4px;

        .name {
            flex-shrink: 0;
            width: 80px;
            color: #ffffff;
            font-size: 12px;
            text-align: end;
        }

        .line {
            width: 100%;
            height: 10px;
            display: flex;
            align-items: center;

            .inner-line {
                position: relative;
                height: 8px;
                background: linear-gradient(269deg, #1B7EF2 0%, rgba(27, 126, 242, 0) 99%);

                .point {
                    position: absolute;
                    right: -20px;
                    top: -8px;
                    width: 20px;
                    height: 20px;
                    border-radius: 50%;
                    border: 1px solid #1B7EF2;
                    background-color: #161616;
                    display: flex;
                    align-items: center;
                    justify-content: center;

                    .shado {
                        width: 5px;
                        height: 5px;
                        background: #FFFFFF;
                        border-radius: 50%;
                        border: 0.83px solid #1B7EF2;
                        box-shadow: 0px 0px 4.17px 1px rgba(255, 255, 255, 0.44);
                    }
                }
            }
        }
    }

    .deptData-top {
        display: flex;
        align-items: center;
        margin-bottom: 20px;
    }
}

.wh140 {
    width: 140px;
    height: 140px;
}

.gradient-text {
    background: linear-gradient(180deg, #FFFFFF 25%, #8DD8E9 57%, #00C3DF 72%);
    /*设置渐变的方向从左到右 颜色从ff0000到ffff00*/
    -webkit-background-clip: text;
    /*将设置的背景颜色限制在文字中*/
    -webkit-text-fill-color: transparent;
    /*给文字设置成透明*/
}

.fw-600 {
    font-weight: 600;
}

.fw-700 {
    font-weight: 700;
}

.fs-18 {
    font-size: 18px;
}

.fc-ffffff {
    color: #ffffff;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.topThree {
    color: #FFA649;
    font-size: 16px;
    font-style: italic;
}

.afterThree {
    font-size: 16px;
    font-style: italic;
    color: #ffffff;
}

.personmsg {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.headImg {
    position: relative;

    .crown {
        position: absolute;
        width: 38px;
        height: 34px;
        top: -22px;
        left: -6px;
    }

    margin-right: 12px;
    width: 64px;
    height: 64px;

    .img {
        width: 100%;
        height: 100%;
        border-radius: 50%;
    }
}

.scroll-wrap {
    width: 100%;
    height: 150px;
    box-sizing: border-box;
    overflow: hidden;
}

.item {
    width: 100%;
    height: 150px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
}

.leftmsg {
    flex-shrink: 0;
    width: 29%;
    -ms-overflow-style: none;
    /* IE 10+ */
    overflow-y: scroll;
    // width: 470px;
    height: calc(100vh - 240px);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

::-webkit-scrollbar {
    display: none;
    /* Chrome Safari */
}
</style>